package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.entity.User;
import com.project.mapper.TUserMapper;
import com.project.service.ITUserService;
import com.project.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author zhangyang
 * @since 2021-10-06
 */
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, User> implements ITUserService {

    @Autowired
    private TUserMapper userMapper;

    @Override
    public UserVo login(String name, String pwd) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("u_name", name);
        wrapper.eq("u_pwd", pwd);
        User user = userMapper.selectOne(wrapper);
        UserVo userVo = new UserVo();
        if (user == null) {
            userVo.setInfo(1);
            return userVo;
        }
        userVo.setUser(user);
        userVo.setInfo(0);
        return userVo;
    }
}
